package cn.ano;

import java.lang.reflect.Method;

/**
 * @author oldliu
 * @since 1.0
 */
public class Test {
    public static void main(String[] args) throws Exception {
        Calculator c=new Calculator();
        Method add = c.getClass().getDeclaredMethod("subtract", int.class, int.class);
        if(add.isAnnotationPresent(MyTest.class)){//是否存在某个注解
            MyTest m=add.getDeclaredAnnotation(MyTest.class);//获得某个注解
            System.out.println(m.before());
            Object invoke = add.invoke(c, 10, 20);
            System.out.println("结果是" +invoke);
            System.out.println(m.after());
        }else {
            Object invoke = add.invoke(c, 10, 20);
            System.out.println("结果是" +invoke);
        }
        //int add = c.add(4, 6);
        //System.out.println(add);
    }
}
